home *** CD-ROM | disk | FTP | other *** search
- Path: news.magmacom.com!not-for-mail
- From: ezust@mag1.magmacom.com (Acme Instant Dehydrated Boulder Kit)
- Newsgroups: comp.lang.c++
- Subject: Re: C++ complex numbers slow as molasses?
- Date: 15 Apr 1996 09:56:23 -0400
- Organization: Cloud-Zero, Canada
- Message-ID: <4ktki7$vft@mag1.magmacom.com>
- References: <4k6k8c$8h4@nyx.cs.du.edu> <9604071851.AA001o1@lorelei.demon.co.uk> <4ke5ap$b8b@mag1.magmacom.com> <Pine.LNX.3.91.960412073943.308E-100000@quoin1.quoininc.com>
- NNTP-Posting-Host: mag1.magmacom.com
-
- In article <Pine.LNX.3.91.960412073943.308E-100000@quoin1.quoininc.com>,
- Jean Pierre LeJacq <jplejacq@quoininc.com> wrote:
- >
- >I agree with the basic idea but I prefer to distinguish member
- >functions as either referenced or value based. OO languages are
-
-
- Thanks for pointing that out to me. I was not familiar with a term
- that would describe this phenomenon.
-
-
- >more efficient manipulating existing objects (referenced based)
- >than creating new one (value based). Fortunately, C++ provides
- >both types of operators so it isn't necessary to define functions
- >like "add()". Instead,
- >
- >class complex {
- > public:
- > complex & operator +=(complex const & lhs);
- >};
-
- The choices are:
-
- If you use the +=, you must first initialize the destination explicitly, and
- then call it twice to achieve the same functionality as one call to the
- binary operator+
-
- Or, you can make one call to a 2-operand member function. Some people like
- using the += in place of the +, others would rather achieve some semantic
- which resembles the + operator. It's just a matter of personal taste, IMHO.
-
- But if one is really concerned about runtime efficiency, chances are that a
- 2-operand member function add can be written so it is more efficient than
- the operator+= used in the way described above.
-
-
- --
- Alan Ezust "Just because I work for the federal
- Ottawa, Canada government doesn't mean I'm an expert
- ezust@magmacom.com on cockroaches" -Special Agent Fox Mulder
- http://www2.magmacom.com/~ezust
-